package com.holyant.goods.enums;

/**
 * @Auther: tswsoft
 * @Date: 2021/03/24/3:27 PM
 * @Description: 报价方式
 */
public enum QuotMethodEnum {

    POST_NOTAX(10, "包邮不包税"),
    POST_TAX(20, "包邮包税"),
    NO_POST_NO_TAX(30, "不包邮不包税");

    private final Integer code;
    private final String name;

    QuotMethodEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (QuotMethodEnum item : QuotMethodEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (QuotMethodEnum item : QuotMethodEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static QuotMethodEnum parse(Integer code) {
        for (QuotMethodEnum item : QuotMethodEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static QuotMethodEnum parseByName(String name) {
        for (QuotMethodEnum item : QuotMethodEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
